from selenium.webdriver.common.by import By
from driver.driver_init import Start
from time import sleep
start=Start("127.0.0.1:62001","7.1.2")
# 定位美食地图定位器
ele_good_map_locator =(By.XPATH,'//android.widget.TextView[@text="美食地图"]')
# 定位商品详情页定位器
ele_good_details_locator =(By.XPATH,'	/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout[2]/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[3]/android.view.View/android.view.View[1]/android.view.View[1]')
# 定位客服定位器
ele_service_locator = (By.XPATH,'//android.view.View[@text="客服"]')
# 定位客服里取消定位器
ele_cancel_locator =(By.ID,'com.gfeng.daydaycook:id/cancel_textview')
# 定位购物车定位器
ele_shoppingcart_locator =(By.XPATH,'//android.widget.ListView/android.view.View[3]')
# 从购物车返回定位器
ele_return_locator =(By.XPATH,'//android.widget.ImageButton[@resource-id="com.gfeng.daydaycook:id/backButton"]')
# 定位首页定位器
ele_homepage_locator =(By.XPATH,'//android.view.View[@text="首页"]')



class GoodMap():
    def good_map_loctaor(self):
        """点击美食地图"""
        self.driver.find_element(*self.ele_good_map_locator).click()
        sleep(5)

    def good_details_locator(self):
        """点击进入商品详情页"""
        self.driver.find_element(*self.ele_good_details_locator).click()
        sleep(5)

    def service_locator(self):
        """点击客服"""
        self.driver.find_element(*self.ele_service_locator).click()
        sleep(5)

    def cancel_locator(self):
        """点击客服里取消"""
        self.driver.find_element(*self.ele_cancel_locator).click()
        sleep(5)

    def shoppingcart_locator(self):
        """点击购物车"""
        self.driver.find_element(*self.ele_shoppingcart_locator).click()
        sleep(5)

    def return_locator(self):
        """点击从购物车返回"""
        self.driver.find_element(*self.ele_return_locator).click()
        sleep(5)

    def homepage_locatou(self):
        """点击首页"""
        self.driver.find_element(*self.ele_homepage_locator).click()
        sleep(5)


# def map(self):
#     self.good_map_locator()
#     self.good_details_locator()
#     self.service_locator()
#     self.cancel_locator()
#     self.shoppingcart_locator()
#     self.return_locator()
#     self.homepage_locator()
